import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.stream.Collectors;

public class java05 {
    public static void main(String[] args) {
        String filePath = "";  // 替换为实际的文件路径
        sortAndWriteBack(filePath);
    }

    public static void sortAndWriteBack(String filePath) {
        try (FileReader reader = new FileReader(filePath);
             FileWriter writer = new FileWriter(filePath)) {

            char[] buffer = new char[1024];
            int numRead;
            StringBuilder content = new StringBuilder();
            while ((numRead = reader.read(buffer)) > 0) {
                content.append(new String(buffer, 0, numRead));
            }

            String line = content.toString();
            String[] numbers = line.split("-");
            String intNumbers = Arrays.stream(numbers)
                    .mapToInt(Integer::parseInt)
                    .sorted()
                    .mapToObj(Integer::toString)
                    .collect(Collectors.joining("-"));

            writer.write(intNumbers);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
